$(function () {
    layui.use(['form'], function () {
        var p_layer = parent.layui.layer,
            util = layui.util;
        util.on({
            choose: function (that) {
                var title = that.attr('data-title'),
                    url = that.attr('data-url'),
                    fun = that.attr('data-fun');
                p_layer.open({
                    type: 2,
                    title: title,
                    shadeClose: true,
                    shade: 0.8,
                    area: ['90%', '90%'],
                    content: url,
                    success: function (layero, index) {
                        var iframeWin = parent.window[layero.find('iframe')[0]['name']];
                        iframeWin.layui.table.on('row(table)', function (obj) {
                            eval(fun + "(" + JSON.stringify(obj.data) + ")");
                            p_layer.close(index);
                        });
                    },
                });
            }
        });
    });
});